<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    
</head>
<body>
    <div id='box'>
		<button id='add'>添加按钮</button>
		<hr/>
		<a href='#' target='_blank'>搜狗1</a>
		<a href='#' target='_blank'>搜狗2</a>
		<a href='#' target='_blank'>搜狗3</a>
		<a href='#' target='_blank'>搜狗4</a>
		<a href='#' target='_blank'>搜狗5</a>
		
	</div>
	<script>
		document.getElementById('add').onclick=function(){
				console.log('111');
				var a=document.createElement('a');
				a.href='#';
				a.target='_blank';
				a.innerHTML='百度';
				var aList=document.getElementsByTagName('a');
				//aa();
				document.getElementById('box').appendChild(a);
				aa();
			}
			function aa(){
				var aList=document.getElementsByTagName('a');
				console.log('aList=====>',aList);
				for(var i=0,len=aList.length;i<len;i++){
				 console.log(aList[i]);
				 aList[i].setAttribute('href','www.baidu.com');
				}
			}
	        aa();
	</script>
</body>
</html>